|
class Transformation |
|
Parent: Object |
|
|
Methods: axes, interpolate, new, rotation, scaling, translation, *, clone, identity?, inverse, invert!, origin, set!, to_a, xaxis, yaxis, zaxis |
|
|
Sample Code: transformationtests.rb |
|
|
Class Methods |
|
axes |
|
The axes method is used to create a Transformation that goes from world coordinates to an arbitrary coordinate system defined by an origin and three axis vectors. |
|
Syntax: |
|
transformation = Geom::Transformation.axes origin, xaxis, yaxis, zaxis |
|
Arguments: |
|
origin - a Point3d object representing the origin (0,0,0 point of the arbitrary coordinate system) xaxis - a Vector3d object representing the direction of the x axis. yaxis - a Vector3d object representing the direction of the y axis. zaxis - a Vector3d object representing the direction of the z axis. |
|
Return Value: |
|
transformation - a new Transformation object |
|
Comments: |
|
|
|
Example: |
|
|
|
interpolate |
|
The interpolate method is used to create a new transformation that is the result of interpolating between two other transformations. |
|
Syntax: |
|
transformation3 = Geom::Transformation.interpolate transformation1, transformation2, parameter |
|
Arguments: |
|
transformation1 - a Transformation object transformation2 - a Transformation object parameter - a value between 0 and 1 (see comments) |
|
Return Value: |
|
transformation3 - the new Transformation object |
|
Comments: |
|
Parameter is a percent (between 0 and 1) that identifies whether to favor transformation1 or transformation2. |
|
Example: |
|
|
|
new |
|
The new method is used to create a new transformation. |
|
Syntax: |
|
transformation = Geom::Transformation.new transformation = Geom::Transformation.new point transformation = Geom::Transformation.new vector transformation = Geom::Transformation.new transformation transformation = Geom::Transformation.new array transformation = Geom::Transformation.new scale transformation = Geom::Transformation.new origin, zaxis transformation = Geom::Transformation.new point, xaxis, yaxis transformation = Geom::Transformation.newpoint, axis, angle transformation = Geom::Transformation.new xaxis, yaxis, zaxis, origin |
|
Arguments: |
|
point - a Point3d object vector - a Vector3d object transformation - a Transformation object array - an Array object scale - a single numeric values used to set a global scale factor for the transform origin - a Point3d object representing the origin (0,0,0 point of the arbitrary coordinate system) xaxis - a Vector3d object representing the direction of the x axis. yaxis - a Vector3d object representing the direction of the y axis. zaxis - a Vector3d object representing the direction of the z axis. |
|
Return Value: |
|
tranformation - a new Transformation object |
|
Comments: |
|
You can use this method or one of the more specific methods for creating specific kinds of Transformations. Geom::Transformation.new with no arguments creates a new identify Transformation. Geom::Transformation.new(pt) creates a Transformation that translates the origin to pt. Geom::Transformation.new(vec) creates a Transformation that translates by vector vec. Geom::Transformation.new(transform) creates a Transformation that is a copy of another Transformation. This is equivalent to transform.clone. Geom::Transformation.new(array) creates a Transformation from a 16 element Array. Geom::Transformation.new(scale) creates a Transformation that does uniform scaling. Geom::Transformation.new(origin, zaxis) creates a Transformation where origin is the new origin, and zaxis is the z axis. The x and y axes are determined using an arbitrary axis rule. Geom::Transformation.new(pt, xaxis, yaxis) create a Transformation given a new origin, x axis and y axis. Geom::Transformation.new(pt, axis, angle) creates a Transformation that rotates by angle (given in radians) about a line defined by pt and axis. |
|
Example: |
|
point = Geom::Point3d.new 10,20,30 |
|
rotation |
|
The rotation method is used to create a Transformation that does rotation about an axis. |
|
Syntax: |
|
transformation = Geom::Transformation.rotation point, vector, angle |
|
Arguments: |
|
point - a Point3d object vector - a Vector3d object angle - a numeric value, expressed in radians, that specifies the angle to rotate about the axis set by the second parameter |
|
Return Value: |
|
transformation - a new Transformation object |
|
Comments: |
|
The axis is defined by a point and a vector. The angle is given in radians. |
|
Example: |
|
|
|
scaling |
|
The scaling method is used to create a Transformation that does scaling. |
|
Syntax: |
|
transformation = Geom::Transformation.scaling scale transformation = Geom::Transformation.scaling point, scale transformation = Geom::Transformation.scaling xscale, yscale, zscale transformation = Geom::Transformation.scaling point, xscale, yscale, zscale |
|
Arguments: |
|
scale - a single numeric values used to set a global scale factor for the transform xscale - a numeric value specifying the scale factor in the x direction for the transform yscale - a numeric value specifying the scale factor in the y direction for the transform zscale - a numeric value specifying the scale factor in the z direction for the transform point - a Point3d object |
|
Return Value: |
|
transformation - a new Transformation object |
|
Comments: |
|
Create a Transformation that does scaling. With one argument, it does a uniform scale about the origin. With two arguments, it does a uniform scale about an arbitrary point. With three arguments, it does a non-uniform scale about the origin. With four arguments it does a non-uniform scale about an arbitrary point |
|
Example: |
|
|
|
translation |
|
The translation method is used to create a transformation that does translation. |
|
Syntax: |
|
transformation = Geom::Transformation.translation vector |
|
Arguments: |
|
vector - a Vector3d object |
|
Return Value: |
|
transformation - a new Transformation object |
|
Comments: |
|
|
|
Example: |
|
|
|
Instance Methods |
|
* |
|
The * method is used to do matrix multiplication using the Transform. |
|
Syntax: |
|
point2 = transformation * point1 vector2 = transformation * vector1 transformation2 = transformation * transformation1 |
|
Arguments: |
|
point1 - a Point3d object vector1 - a Vector3d object transformation1 - a Transformation object |
|
Return Value: |
|
point2 - a new Point3d object vector2 - a new Vector3d object transformation2 - a new Transformation object |
|
Comments: |
|
|
|
Example: |
|
|
|
clone |
|
The clone method is used to create a copy of a transformation. |
|
Syntax: |
|
transformation2 = transformation1.clone |
|
Arguments: |
|
|
|
Return Value: |
|
transformation2 - a new Transformation object (clone of transformation1) |
|
Comments: |
|
|
|
Example: |
|
|
|
identity? |
|
The identity? method is used to determine if a transformation is the identity transform. |
|
Syntax: |
|
status = transformation.identify? |
|
Arguments: |
|
|
|
Return Value: |
|
status - true if the transformation is the identity transform, false if it is not the identity transform. |
|
Comments: |
|
|
|
Example: |
|
|
|
inverse |
|
The inverse method is used to retrieve the inverse of a transformation. |
|
Syntax: |
|
transformation2 = transformation1.inverse |
|
Arguments: |
|
|
|
Return Value: |
|
transformation2 - the Transformation object at its inverse |
|
Comments: |
|
|
|
Example: |
|
|
|
invert! |
|
The invert! method sets the transformation to its inverse. |
|
Syntax: |
|
transformation = transformation.invert! |
|
Arguments: |
|
|
|
Return Value: |
|
transformation - the Transformation object at its inverse. |
|
Comments: |
|
|
|
Example: |
|
|
|
origin |
|
The origin method retrieves the origin of a rigid transformation. |
|
Syntax: |
|
point = transformation.origin |
|
Arguments: |
|
|
|
Return Value: |
|
point - a Point3d object representing the origin of the transformation |
|
Comments: |
|
|
|
Example: |
|
|
|
set! |
|
The set! method is used to set this transformation to match another one |
|
Syntax: |
|
transformation1 = transformation1.set! transformation2 |
|
Arguments: |
|
transformation2 - a Transformation object to match |
|
Return Value: |
|
transformation1 - a Transformation object matching transformation2 |
|
Comments: |
|
The argument is anything that can be converted into a Transformation. |
|
Example: |
|
|
|
to_a |
|
The to_a method retrieves a 16 element array which contains the values that define the Transformation. |
|
Syntax: |
|
array = transformation.to_a |
|
Arguments: |
|
|
|
Return Value: |
|
array - an Array element containing the values that define the transformation |
|
Comments: |
|
|
|
Example: |
|
|
|
xaxis |
|
The xaxis method retrieves the x axis of a rigid transformation. |
|
Syntax: |
|
point = transformation.xaxis |
|
Arguments: |
|
|
|
Return Value: |
|
point - a Point3d object containing the xaxis value |
|
Comments: |
|
|
|
Example: |
|
|
|
yaxis |
|
The yaxis method retrieves the y axis of a rigid transformation. |
|
Syntax: |
|
point = transformation.yaxis. |
|
Arguments: |
|
|
|
Return Value: |
|
point - a Point3d object containing the yaxis value |
|
Comments: |
|
|
|
Example: |
|
|
|
zaxis |
|
The zaxis method retrieves the z axis of a rigid transformation. |
|
Syntax: |
|
point = transformation.zaxis |
|
Arguments: |
|
|
|
Return Value: |
|
point - a Point3d object containing the zaxis value |
|
Comments: |
|
|
|
Example: |
|
|